<template>
	<div class="deliberate">
		<div class="title">
			{{loadData.name}}
		</div>
		<van-divider />
		<div class="content">
			<div class="list" v-for="item in list" :key="item.id">
				<div class="left">
					<div class="name">{{item.title}}</div>
					<div class="time">截止日期：{{item.endtime_text}}</div>
				</div>
				<div class="right" @click="todetail(item)" v-if="item.deliberate==0">
					去投票
				</div>
				<div class="right active" v-if="item.deliberate>0">
					已投票
				</div>
			</div>

		</div>
	</div>
</template>

<script>
	export default {
		name: "Deliberate",
		components: {

		},
		data() {
			return {
				loadData: {},
				list: [],
				userInfo: {}
			}
		},
		mounted() {
			this.userInfo = JSON.parse(this.$getcookie("userInfo"))
			this.loadData = this.$localStorage.get("secondLevel")
			this.getData()
		},
		methods: {
			getData() {
				let detailData = {
					user_id: this.userInfo.user_id,
					token: this.$getcookie("jy_token"),
					site_id: 0,
					type: this.loadData.url
				}
				this.$api.home.voteList(detailData).then(res => {
					// 执行某些操作
					if (res.code == 1) {
						this.list = res.data.data
					}

				})
			},
			todetail(item) {

				this.$router.push({
					path: `/classify/deliberatedetail?id=${item.id}`
				})



			}
		}




	}
</script>

<style lang="less">
	.deliberate {
		padding: 1.13rem 0.78rem;
		background: #fff;

		.title {
			font-size: 0.94rem;
			font-family: PingFang SC;
			font-weight: bold;
			color: rgba(38, 38, 38, 1);
		}

		.content {
			padding-top: 0.5rem;

			.list {
				margin-bottom: 2.28rem;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.left {
					.name {
						font-size: 0.88rem;
						font-family: PingFang SC;
						font-weight: 500;
						color: rgba(54, 54, 54, 1);
						line-height: 1.25rem;
						margin-bottom: 0.94rem;
					}

					.time {
						font-size: 0.69rem;
						font-family: PingFang SC;
						font-weight: 500;
						color: rgba(147, 147, 147, 1);
					}
				}

				.right {
					width: 4.13rem;
					height: 2.19rem;
					background: rgba(254, 119, 0, 1);
					border-radius: 1rem;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 0.88rem;
					font-family: PingFang SC;
					font-weight: 500;
					color: rgba(255, 255, 255, 1);

					&.active {
						opacity: 0.5;
					}
				}

			}
		}
	}
</style>
